import { useEffect, useState } from 'react';

const Counter = () => {
    const [count, setCount] = useState(0);
    useEffect(() => {
        let timer = setInterval(() => {
            // setCount(count + 1);
            setCount(count => count + 1);
        }, 1000)
        return () => clearInterval(timer);
    }, [])
    return (
        <span>{count}</span>
    )
}

export default Counter;
